<template>
  <div class="box">
    爷爷组件--钱包: {{ money }}--{{ info }}
    <button @click="pay()">花钱</button>
    <button @click="info.age++">修改年龄</button>
    <BaseA />
  </div>
</template>

<script>
import BaseA from './components/BaseA.vue';

export default {
  components: {
    BaseA,
  },
  data() {
    return {
      money: 100000,
      info: {
        username: '张三',
        age: 18
      }
    }
  },
  provide() {
    return {
      // 非响应式的
      money: this.money,
      // 响应式的
      info: this.info
    }
  },
  methods: {
    pay() {
      this.money -= 1000;
    }
  }
}
</script>

<style>
.box {
  width: 500px;
  height: 400px;
  background-color: red;
}
</style>
